﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mfApplyDjack.aspx.cs" Inherits="msBsc.WebUi.mMall.Buyer.mfApplyDjack1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>手机地接客商城</title>
    <%=getMeta()%>
    <link rel="stylesheet" type="text/css" href="/themes/mStyle1/mGlobal.css" charset="gbk" />
    <link rel="stylesheet" type="text/css" href="/themes/mStyle1/css/home/base.css" charset="gbk" />
    <link rel="stylesheet" type="text/css" href="/themes/mStyle1/css/public/mLogin.css" charset="gbk" />
    <link href="/jqPlugin/laydate/skins/default/laydate.css" rel="stylesheet" />
    <link href="/themes/mStyle1/css/Buyer/mTouristInfo.css" rel="stylesheet" />
    <link href="/jqPlugin/Jcrop/css/jquery.Jcrop.min.css" rel="stylesheet" charset="gbk" />
    <%=getBodyBeforeJs()%>
    <script type="text/javascript" src="/jqPlugin/js/jBase.js"></script>
    <script type="text/javascript">
        $(window).load(function () {
        });
        //        $(window).bind('resize', function () { _self._ResizeHandler(_self); })
        //        .bind('scroll', function () { _self._ResizeHandler(_self); });
    </script>
    <!--head fix rgn-->
    <style type="text/css">
        
    </style>
    <base target="_self" />
</head>
<body>
    <div class="viewport">
        <%=msBsc.WebUi.Code.QtHtmlGet.GetWapHeaderMenuHtml(true) %>
        <form action='#' method="post" id="J_EmailForm">
            <div class="t_Header">
                <div>
                    <img class="u_Avatar" id="headPhoto" src="" />
                </div>
                <div style="margin-top: 20px;">
                    <a class="c_userAvatar">
                        <input type="file" name="image_file" id="image_file" style="width: 154px; height: 38px; opacity: 0;" />
                    </a>
                </div>
            </div>
            <div class="demo" style="display: none;">
                <input type="button" value="取 消" class="btn_upload btn_clear_upload" onclick="clearDotest();" />
                <div class="step2">
                    <img id="preview" />
                </div>
            </div>
            <div class="m_t_type">
                <a class="m_t_img m_t_basic"></a><span class="m_t_name">基本信息</span>
            </div>
            <div style="margin-top: 20px;">
                <div class="c_u_title">
                    昵称<span class="important">*</span>
                </div>
                <div>
                    <div class="c_input">
                        <input type="text" value="" name="username" id="u_Nicke" placeholder="请输入昵称" />
                    </div>
                </div>
                <div class="c_u_title">
                    姓名<span class="important"></span>
                </div>
                <div>
                    <div class="c_input">
                        <input type="text" value="" name="username" id="u_Name" placeholder="请输入姓名" />
                    </div>
                </div>
                <div class="c_u_title">
                    性别<span class="important"></span>
                </div>
                <div>
                    <div class="c_input">
                        <input type="radio" value="M" class="gender" name="sex" id="u_m_gender" />
                        男
                        <input type="radio" value="F" class="gender" name="sex" id="u_w_gender" />女

                    </div>
                </div>
                <div class="c_u_title">
                    证件号<span class="important"></span>
                </div>
                <div>
                    <div class="c_input">
                        <div class="cred_type">
                            <div class="cred_type_cell_1">
                                <select id="card-select">
                                    <option value="1">身份证</option>
                                    <option value="2">护照</option>
                                    <option value="3">驾照</option>
                                </select>
                            </div>
                            <div class="cred_type_cell_2">
                                <input type="text" id="txtIdCard" placeholder="请输入证件号" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="c_u_title">
                    所在地<span class="important">*</span>
                </div>
                <div>
                    <div class="c_input">
                        <div class="seat">
                            <select id="country_select">
                                <option>中国</option>
                            </select>
                        </div>
                        <div class="seat">
                            <select id="city_select">
                                <option>新疆</option>
                            </select>
                        </div>
                        <div class="seat">
                            <select id="destion_select">
                                <option>乌鲁木齐</option>

                            </select>
                        </div>
                    </div>
                </div>

                <div class="c_u_title">
                    服务类型<span class="important"></span>
                </div>
                <div>
                    <div class="c_input">
                        <select id="service-type">
                            <option value="1">司机兼导游</option>
                            <option value="2">司机兼向导</option>
                            <option value="3">专职司机+专业导游</option>
                        </select>
                    </div>
                </div>
                <div class="c_u_title">
                    服务标签
                </div>
                <div>
                    <div class="c_input">
                        <ul class="label_user">
                            <li>
                                <input type="checkbox" name="ServiceLabel" value="1" />
                                <label>免费旅游咨询</label>
                            </li>
                            <li>
                                <input type="checkbox" name="ServiceLabel" value="2" />
                                <label>旅游定制</label>
                            </li>
                            <li>
                                <input type="checkbox" name="ServiceLabel" value="3" />
                                <label>导游服务</label>
                            </li>
                            <li>
                                <input type="checkbox" name="ServiceLabel" value="4" />
                                <label>向导服务</label>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="c_u_title">
                    自我介绍
                </div>
                <div>
                    <div class="c_input">
                        <textarea id="tatSelfIntro"></textarea>
                    </div>
                </div>
            </div>
            <div class="m_t_type">
                <a class="m_t_img"></a><span class="m_t_name">联系方式</span>
            </div>
            <div style="margin-top: 20px;">
                <div class="c_u_title">
                    移动电话<span class="important">*</span>
                </div>
                <div>
                    <div class="c_input">
                        <input type="text" value="" name="username" id="u_mobile" placeholder="请输入移动电话" />
                    </div>
                </div>
                <div class="c_u_title">
                    固定电话
                </div>
                <div>
                    <div class="c_input">
                        <input type="text" value="" name="username" id="u_phone" placeholder="请输入固定电话" />
                    </div>
                </div>
                <div class="c_u_title">
                    QQ
                </div>
                <div>
                    <div class="c_input">
                        <input type="text" value="" name="username" id="u_QQ" placeholder="请输入QQ" />
                    </div>
                </div>
                <div class="c_u_title">
                    邮箱<span class="important">*</span>
                </div>
                <div>
                    <div class="c_input">
                        <input type="text" value="" name="username" id="u_email" placeholder="请输入邮箱" />
                    </div>
                </div>
                <div class="c_u_title">
                    微信：
                </div>
                <div>
                    <div class="c_input">
                        <input type="text" value="" name="username" id="u_wechat" placeholder="请输入微信" />
                    </div>
                </div>
            </div>
            <div>
                <input type="button" class="btn btn-large btn_size" onclick="apply()" value="立即申请" id="applyDjack" />
            </div>
            <%=msBsc.WebUi.Code.QtHtmlGet.GetWapMenuHtml() %>
        </form>
        <script type="text/javascript" src="/jqPlugin/js/jquery-1.8.3.min.js" charset="gbk"></script>
        <script type="text/javascript" src="/jqPlugin/js/jBase.js" charset="gbk"></script>
        <script type="text/javascript" src="/jqPlugin/js/jBPage.js" charset="gbk"></script>
        <script type="text/javascript" src="/themes/Style1/jsQt.js" charset="gbk"></script>
        <script type="text/javascript" src="/jqPlugin/js/laytpl.js" charset="gbk"></script>
        <script type="text/javascript" src="/jqPlugin/laydate/laydate.js" charset="gbk"></script>
        <script type="text/javascript" src="/themes/wStyle1/js/comm/VerifyJs.js" charset="gbk"></script>
        <script type="text/javascript" src="/themes/wStyle1/js/comm/DateInfo.js" charset="gbk"></script>
        <script type="text/javascript" src="/jqPlugin/Jcrop/js/jquery.Jcrop.min.js" charset="gbk"></script>
        <script type="text/javascript">
            var initImg = "";
            (function () {

                InitImgUpload("image_file", "preview", 600, [40, 40], [450, 450], function (_base64) {
                    //没剪切前返回压缩后的值，剪切后返回剪切的值,可以将这个值赋值给IMG控件进行预览
                    $("#headPhoto").attr("src", _base64);
                });

                $("#h_title").text("成为地接客");
                $.getMessageCount();
                //改变国家
                $("#country_select").change(function () {
                    var _jsParam = new jsonRow();
                    _jsParam.AddCell("parentsId", $(this).val());
                    _jsParam.AddCell("isAll", "false");
                    _jsParam.AddCell("ACTION", "upCountry");
                    ajaxComm(_jsParam);
                });
                //改变城市
                $("#city_select").change(function () {
                    var _jsParam = new jsonRow();
                    _jsParam.AddCell("parentsId", $(this).val());
                    _jsParam.AddCell("isAll", "false");
                    _jsParam.AddCell("ACTION", "upCity");
                    ajaxComm(_jsParam);
                });
            })()
            function clearDotest() {
                $("#headPhoto").attr("src", initImg);
                $(".demo").hide();
                $(".step2").html("");
                $(".step2").html("<img id='preview' />");
            }
            function btnDo() {
                var _jsParam = new jsonRow();
                _jsParam.AddCell("parentsId", "00000000-0000-0000-0000-000000000000");
                _jsParam.AddCell("isAll", "false");
                _jsParam.AddCell("ACTION", "init");
                ajaxComm(_jsParam);
            };
            btnDo();
            //显示个人资料
            function showUserInfo(data) {
                $("#headPhoto").attr("src", getUserPhoto(data.rows[0].CUSTOMER_DEFAULT_PIC, data.CUSTOMER_BASEINFO_GENDER) + " 114x114img.jpg");
                initImg = getUserPhoto(data.rows[0].CUSTOMER_DEFAULT_PIC, data.CUSTOMER_BASEINFO_GENDER) + " 114x114img.jpg";
                //$("#imgHead").html("<img src='/Filters/Djack/" + getUserPhoto(data.HeadPhotoName, data.Gender) + "' />");
                if (!IsNull(data.rows[0].CUSTOMER_NICK)) {
                    $("#u_Nicke").val(data.rows[0].CUSTOMER_NICK);
                }

                if (!IsNull(data.rows[0].CUSTOMER_BASEINFO_GENDER)) {
                    if (data.rows[0].CUSTOMER_BASEINFO_GENDER == "M") {
                        $("#u_m_gender").attr("checked", "checked");
                    } else {
                        $("#u_w_gender").attr("checked", "checked");
                    }
                }
                if (!IsNull(data.rows[0].CUSTOMER_BASEINFO_BIRTH)) {
                    $("#u_birth").val(formatDate(new Date(data.rows[0].CUSTOMER_BASEINFO_BIRTH), false));
                }

                if (!IsNull(data.rows[0].CUSTOMER_BASEINFO_MOBILE)) {
                    $("#u_mobile").val(data.rows[0].CUSTOMER_BASEINFO_MOBILE);
                }

                if (!IsNull(data.rows[0].CUSTOMER_BASEINFO_PHONE)) {
                    $("#u_phone").val(data.rows[0].CUSTOMER_BASEINFO_PHONE);
                }

                if (!IsNull(data.rows[0].CUSTOMER_BASEINFO_QQ)) {
                    $("#u_QQ").val(data.rows[0].CUSTOMER_BASEINFO_QQ);
                }

                if (!IsNull(data.rows[0].CUSTOMER_BASEINFO_EMAIL)) {
                    $("#u_email").val(data.rows[0].CUSTOMER_BASEINFO_EMAIL);
                }

                if (!IsNull(data.rows[0].CUSTOMER_WECHAT_NO)) {
                    $("#u_wechat").val(data.rows[0].CUSTOMER_WECHAT_NO);
                }
            }

            //显示地区
            function setCity(data, selectId, selectCity) {
                if (IsNull(data) || data.rows.length < 1) {
                    return;
                }
                $("#" + selectId).html("");
                for (var i = 0; i < data.rows.length; i++) {
                    if (data.rows[i].COUNTRY_CITY_ID == selectCity) {
                        $("#" + selectId).append("<option selected='selected' value='" + data.rows[i].COUNTRY_CITY_ID + "'>" + data.rows[i].COUNTRY_CITY_NME + "</option>");
                    } else {
                        $("#" + selectId).append("<option value='" + data.rows[i].COUNTRY_CITY_ID + "'>" + data.rows[i].COUNTRY_CITY_NME + "</option>");
                    }
                }
            }

            function getUserPhoto(userPhoto, sex) {
                if (userPhoto != undefined && userPhoto != null && userPhoto != "") {
                    return userPhoto;
                }
                if (sex == "M") {
                    return "/UpLoad/Djack/man.jpg";
                } else if (sex == "F") {
                    return "/UpLoad/Djack/wman.jpg";
                } else {
                    return "/UpLoad/Djack/djack.jpg";
                }
            }

            //申请成为地接客
            function apply() {
                if ($("#applyDjack").val() == "正在申请") {
                    return;
                }
                //获取性别
                var sex = $("input[name='sex']:checked").val();

                //获取头像
                var HeadPhoto = $.trim($("#headPhoto").attr("src"));

                if (!IsNull(HeadPhoto)) {
                    //var headArray = HeadPhoto.split('/');
                    //HeadPhoto = headArray[headArray.length - 1];
                    HeadPhoto = HeadPhoto.split(' ')[0];
                }
                else if (IsNull(HeadPhoto)) {
                    if (sex == "M") {
                        HeadPhoto = "/UpLoad/Djack/man.jpg";
                    } else if (sex == "F") {
                        HeadPhoto = "/UpLoad/Djack/wman.jpg";
                    } else {
                        HeadPhoto = "/UpLoad/Djack/djack.jpg"
                    }
                }
                var NickName = $.trim($("#u_Nicke").val());
                //验证昵称
                //if (!vfcUserName(NickName)) {
                //    alert("用户昵称不能为空");
                //    return;
                //}
                //else
                if (NickName.toUpperCase().indexOf("DJK") >= 0 || NickName.toUpperCase().indexOf("地接客") >= 0 || NickName.toUpperCase().indexOf("DIJIEKE") >= 0 || NickName.toUpperCase().indexOf("ADMIN") >= 0 || NickName.toUpperCase().indexOf("ADMINISTRATOR") >= 0 || !isEnLength(NickName, 4, 40)) {
                    alert("用户昵称已占用")
                    return;
                }

                var ChineseName = $.trim($("#u_Name").val());
                //验证姓名
                //if (IsNull(ChineseName)) {
                //    alert("用户姓名不能为空");
                //    return;
                //} else 
                if (ChineseName.toUpperCase().indexOf("DJK") >= 0 || ChineseName.toUpperCase().indexOf("地接客") >= 0 || ChineseName.toUpperCase().indexOf("DIJIEKE") >= 0 || ChineseName.toUpperCase().indexOf("ADMIN") >= 0 || ChineseName.toUpperCase().indexOf("ADMINISTRATOR") >= 0 || ChineseName.length > 15) {
                    alert("用户姓名不合法");
                    return;
                }
                //获取地区信息
                var destionId = $.trim($("#destion_select").val());
                var cityId = $.trim($("#city_select").val());
                var countryId = $.trim($("#country_select").val());
                if (IsNull(destionId) || IsNull(cityId) || IsNull(countryId)) {
                    alert("请选择所在地");
                    return;
                }
                var ServiceType = $.trim($("#service-type").val());
                //if (IsNull(ServiceType)) {
                //    alert("服务类型不能为空");
                //    return;
                //}
                var ServiceLabel = GetCheckedLabels();
                var SelfIntro = $.trim($("#tatSelfIntro").val());
                if (SelfIntro.length > 240) {
                    alert("自我介绍最大为240个字符")
                    return;
                }
                var MobilePhone = $.trim($("#u_mobile").val());
                if (IsNull(MobilePhone)) {
                    alert("手机不能为空");
                    return;
                }
                var Phone = $.trim($("#u_phone").val());
                if (!IsNull(Phone) && !isPhone(Phone)) {
                    alert("固话格式参照023-65360519格式");
                    return;
                }

                //获取QQ
                var TencentQQ = $.trim($("#u_QQ").val());
                if (!IsNull(TencentQQ) && !isQQ(TencentQQ)) {
                    alert("QQ只能是4-12位数字");
                    return;
                }

                //获取邮箱
                var Email = $.trim($("#u_email").val());
                if (IsNull(Email)) {
                    alert("邮箱不能为空");
                    return;
                }
                if (!IsEmail(Email)) {
                    alert("邮箱格式不正确");
                    return;
                }

                //微信
                var WeChat = $.trim($("#u_wechat").val());
                //证件
                var cardType = $("#card-select").val();
                var cardNumber = $.trim($("#txtIdCard").val());
                //if (IsNull(cardType) || IsNull(cardNumber)) {
                //    alert("请输入证件号");
                //    return;
                //}
                var opart = new jsonRow();
                opart.AddCell("ACTION", "applyDjack");
                opart.AddCell("HeadPhoto", HeadPhoto);
                opart.AddCell("postFileNme", $("#image_file").val());
                opart.AddCell("NickName", NickName);
                opart.AddCell("ChineseName", ChineseName);
                opart.AddCell("Gender", sex);
                opart.AddCell("destionId", destionId);
                opart.AddCell("cityId", cityId);
                opart.AddCell("countryId", countryId);
                opart.AddCell("ServiceType", ServiceType);
                opart.AddCell("ServiceLabel", ServiceLabel);
                opart.AddCell("SelfIntro", SelfIntro);
                opart.AddCell("MobilePhone", MobilePhone);
                opart.AddCell("Phone", Phone);
                opart.AddCell("TencentQQ", TencentQQ);
                opart.AddCell("Email", Email);
                opart.AddCell("WeChat", WeChat);
                opart.AddCell("cardType", cardType);
                opart.AddCell("cardNumber", cardNumber);
                $("#applyDjack").val("正在申请");
                ajaxComm(opart);
            }

            //得到用户电话
            function GetPhone() {
                if (($("#txtPhoneTitle").val() == null || $("#txtPhoneTitle").val() == "") && $("#txtPhoneContent").val() != null && $("#txtPhoneContent").val() != "") {
                    return "abc";
                }

                if ($("#txtPhoneTitle").val() != null && $("#txtPhoneTitle").val() != "" && ($("#txtPhoneContent").val() == null || $("#txtPhoneContent").val() == "")) {
                    return "abc";
                }

                if ($("#txtPhoneTitle").val() != null && $("#txtPhoneTitle").val() != "" && $("#txtPhoneContent").val() != null && $("#txtPhoneContent").val() != "") {
                    return $.trim($("#txtPhoneTitle").val()) + "-" + $.trim($("#txtPhoneContent").val());
                } else {
                    return "";
                }
            }

            //获取已选择的服务标签
            function GetCheckedLabels() {
                var ServiceLabel = "";
                var Checkeditems = $("input[type=checkbox][name=ServiceLabel]:checked");
                var CheckedLength = Checkeditems.length;
                $.each(Checkeditems, function (i, item) {
                    if (i < CheckedLength - 1) {
                        ServiceLabel += $(this).val() + "|";
                    }
                    else {
                        ServiceLabel += $(this).val();
                    }

                });
                return ServiceLabel;
            }

            //验证用户昵称
            function vfcUserName(userName) {
                if (IsNull(userName)) {
                    alert("用户昵称不能为空");
                    return false;
                } else if (userName.toUpperCase().indexOf("地接客") >= 0 || userName.toUpperCase().indexOf("DJK") >= 0 || userName.toUpperCase().indexOf("DIJIEKE") >= 0) {
                    alert("用户昵称不可用");
                    return false;
                }
                if (!isEnLength(userName, 0, 40)) {
                    alert("用户昵称最大长度为40个字符，中文算2个字符");
                    return false;
                }
                return true;
            }
        </script>
    </div>
</body>
<%=getBodyAfterJs() %>
</html>


